Projects (uv Concepts)
Project metadata
Defining entry points
[project.scripts]
Build systems
uv uses the presence of a build system to determine if a project contains a package that should be installed in the project virtual environment.
If a build system is not defined, uv will not attempt to build or install the project itself, just its dependencies.
If a build system is defined, uv will build and install the project into the project environment. Projects are installed in editable mode so changes to the source code are reflected immediately, without reinstallation.
IMO:プロジェクト自体をインストールしないか、editable installの2択(と理解している。v0.4)
tool.uv.package(要確認)
Setting tool.uv.package = true will force a project to be built and installed into the project environment.
Setting tool.uv.package = false will force a project package not to be built and installed into the project environment.
Creating projects
Application projects are suitable for web servers, scripts, and command-line interfaces.
A library is a project that is intended to be built and distributed as a Python package,
Packaged applications (uv init --app --packaged)
Project environments
.venv
Project lockfile
To avoid updating the lockfile during uv sync and uv run invocations, use the --frozen flag.
To avoid updating the environment during uv run invocations, use the --no-sync flag.
To assert the lockfile matches the project metadata, use the --locked flag. If the lockfile is not up-to-date, an error will be raised instead of updating the lockfile.
Limited resolution environments(積ん読)
Managing dependencies
uv supports adding editable dependencies, development dependencies, optional dependencies, and alternative dependency sources.
積ん読
Running commands
This environment 注(.venv) is isolated from the current shell by default, so invocations that require the project, e.g., python -c "import example", will fail. Instead, use uv run to run commands in the project environment:
uv run bashの例!
additional dependencies: uv run --with
Scripts that declare inline metadata are automatically executed in environments isolated from the project.
Projects with many packages
workspaceらしい(TODO)
Building projects
Python projects are typically distributed as both source distributions (sdists) and binary distributions (wheels).
The former is typically a .tar.gz or .zip file containing the project's source code along with some additional metadata, while the latter is a .whl file containing pre-built artifacts that can be installed directly.
uv build path/to/project(パスの指定がなければ dist ディレクトリ)
You can limit uv build to building a source distribution with uv build --sdist, a binary distribution with uv build --wheel, or build both distributions from source with uv build --sdist --wheel.
フラグの指定で、wheelだけ作るといったことが可能
Build isolation